package com.example.chat.utils;

import java.util.Base64;

public class Base64Encoding {
    public static String authCode() {
        // 客户 ID
        final String customerKey = "30863f4290724bc8b4bb84bfeaa58bdc";
        // 客户密钥
        final String customerSecret = "e06cc5c02b1048e98cd340d942a5ebb9";

        // 拼接客户 ID 和客户密钥并使用 base64 编码
        String plainCredentials = customerKey + ":" + customerSecret;
        String base64Credentials = new String(Base64.getEncoder().encode(plainCredentials.getBytes()));
        // 创建 authorization header
        String authorizationHeader = "Basic " + base64Credentials;
        System.out.println("code:"+authorizationHeader);
        return authorizationHeader;
//        HttpClient client = HttpClient.newHttpClient();
//        // 创建 HTTP 请求对象
//        HttpRequest request = HttpRequest.newBuilder()
//                .uri(URI.create("https://api.agora.io/v1/apps/<yourappid>/cloud_recording/acquire"))
//                .GET()
//                .header("Authorization", authorizationHeader)
//                .header("Content-Type", "application/json")
//                .build();
//        // 发送 HTTP 请求
//        HttpResponse<String> response = null;
//        try {
//            response = client.send(request,
//                    HttpResponse.BodyHandlers.ofString());
//        } catch (IOException | InterruptedException e) {
//            e.printStackTrace();
//        }

    }
}
